/**
 * Created by   :Wangshuzhong
 * Created time :2019/08/29
 */
require(["vue","ELEMENT"], function (Vue, Element) {
  Vue.use(Element)
  var Config = $("body").data("config"); // 配置文件内容
  //设置导航栏
  window.app = new Vue({
      el: '#app',
      data: {
          activeName: 'about', // 显示的导航
          activeSecName: 'news', // 显示的二级导航
          pageInfo: {
            curPage: 1,
            pageSize: 9,
            code: 'info'
          },
          total: 0,
          newsList: []
      },
      created:function() {
        // 获取动态新闻数据
        this.getNewsList();
      },
      mounted:function() {

      },
      methods: {
          // 获取动态新闻数据
          getNewsList:function() {
            var self = this;
            Config.Request('post', Config.apiUrl.getNews, this.pageInfo).then(function(res) {
              if(res.code == 200) {
                // if(self.newsList.length < 1) {
                //   self.newsList = res.data;
                // } else {
                //   var resList = res.data;
                //   self.newsList = self.newsList.concat(res.data);
                // }
                self.newsList = res.data;
                self.total = res.total
              } else {
                self.$message.error(res.message)
              }
            }).catch(function(error) {
              self.$message.error(error)
            })
          },
          turnTime:function(time) {
            return Config.getRecordDate(time, 2)
          },
          // 详情
          viewNewInfo:function(id) {
            window.location.href = 'newsInfo.html' + '?code=' + id;
          },
          // 分页
          changePage:function(nowPage) {
            this.pageInfo.curPage = nowPage
            this.getNewsList();
          },
      }
  });
})
